package com.abc.scholarship.controller;


import com.abc.scholarship.domain.page.PageDTO;
import com.abc.scholarship.domain.page.PageQuery;
import com.abc.scholarship.domain.vo.resp.ApiResult;
import com.abc.scholarship.domain.vo.resp.ResultResp;
import com.abc.scholarship.service.ApplyResService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 结果表 前端控制器
 * </p>
 *
 * @author jzw
 * @since 2024-07-02
 */
@Api(tags = "结果接口")
@RestController
@RequestMapping("/result")
public class ApplyResController {

    @Autowired
    private ApplyResService applyResService;

    @ApiOperation("生成奖学金获取结果")
    @PostMapping("/post")
    public ApiResult<String> postScholarshipRes(){
        new Thread(() -> {
            applyResService.postScholarshipRes();
        }).start();

        return ApiResult.success("生成成功");
    }

    @ApiOperation("管理员查询获奖结果")
    @GetMapping("/admin/list")
    public ApiResult<List<ResultResp>> adminGetScholarshipRes(){
        return ApiResult.success(applyResService.getScholarshipRes());
    }

    @ApiOperation("学生查询获奖结果")
    @GetMapping("/stu/list")
    public ApiResult<List<ResultResp>> stuGetScholarshipRes(){
        return ApiResult.success(applyResService.stuGetScholarshipRes());
    }

    @ApiOperation("导出奖学金结果")
    @GetMapping("/export")
    public void exportResult(){
        applyResService.exportResult();
    }

}

